package niuke;

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

/**
 * Created by hua66 on 2017/8/28.
 */
public class TTae {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			int[] nums = new int[m];
			for (int i = 0; i < m; i++) {
				nums[i] = sc.nextInt();
			}

			printKolakoski(n, nums);
		}
	}

	public static void printKolakoski(int n, int[] nums) {
		int index = -1;
		int countDown = 0;
		Queue<Integer> history = new LinkedList<>();//用一个队列存储count（也是输出

		for (int i = 0; i < n; i++) {
			boolean flag = true;
			if (countDown == 0) {
				index = getNextIndex(index, nums.length);
				if (history.isEmpty()) {
					countDown = nums[index];
					System.out.println(nums[index]);
					countDown--;
					continue;
				} else
					countDown = history.remove();
			}
			System.out.println(nums[index]);
			history.add(nums[index]);
			countDown--;
		}
	}

	public static int getNextIndex(int index, int n) {
		return index + 1 >= n ? 0 : index + 1;
	}
}
